<?php

// include function files for this application
require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php'); 
if (!session_id()) { session_start(); }

$user_attendee_id = $_SESSION['current_attendee_id'];

//We don't people accessing this page during the con.
/*
if (!check_valid_user() || ($_SESSION['admin'] != 't')) {
	do_html_header('Unauthorized access', staysmall);
	echo 'We are sorry, This page is inaccesibe during the con. Thank You.';
	print_brs(24);
	do_html_footer(news);
	exit;
	}
*/

if(!check_valid_user()) {
	do_html_header('Manage UNY-Con payment', staysmall);
	echo 'You are not logged in';
	print_brs(24);
	do_html_footer(news);
	exit;
	}
	
do_html_header('Manage UNY-Con payment', gobig ,$uny);

echo "<p>From this page you can manage paying for your UNY-Con events. All events that have fees are listed below with PayPal add to cart buttons. Once we have received your payment we will update our records and you will no longer see the event listed below. Please allow 24 hours for processing. <b><span class=\"redtext\">Add all events to your cart and then process your payment through PayPal. You will need to return to this page to add each item to your cart.</b><br/>
Please note, while your payment is being processed it will still show up as pending, do not pay twice!</p>
<p>Co-GMs waiting for approval to have their convention fee waived should not pay the convention registration fee, you can still pay for your event fees.</p>
<p>If PayPal is not a feasible form of payment for you, you can print <a href=\"attendee_home.php\">your schedule</a> page and send it with a Check or Money Order, for the full balance owed amount, made payable to Daniel Brace to:<br />
	UNY-Con<br />
	c/o Daniel Brace<br />
	146 Laburnam Crescent<br />
	Rochester, NY 14620<br />
Please allow at least one week for mail-in registration payments. Mail-in registrations must be postmarked no later than October 30th.<br /><br />
Thank you,<br />
The UNY-Con Staff</p><br />\n\n";

//$attendance_status = get_con_attendance_status($_SESSION['attendee_id']);

//check the number of events they are signed up to Co-GM

$running_timeslots = get_number_of_events_run($user_attendee_id);
  if ($cogmevents = get_cogm_events($user_attendee_id, pending)) $cogmnumpending = pg_numrows($cogmevents);
  $runningevents = $running_timeslots + $cogmnumpending;

if ((get_con_attendance_status($user_attendee_id) == 'pending') && ($runningevents < 4)) {
	$date_select = get_con_attendance_day($user_attendee_id);
	echo "<form target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">";
	echo "<input type=\"hidden\" name=\"cmd\" value=\"_cart\">";
	echo "<input type=\"hidden\" name=\"business\" value=\"registration@uny-con.com\">";

	if ($date_select == "all week-end" || $date_select == "all-access") {
		echo "<b>All Access Pass - $25.00 (USD)</b><br />\n";
		echo "<input type=\"hidden\" name=\"item_name\" value=\"All Weekend Pass (Pre-reg)\">\n";
		echo "<input type=\"hidden\" name=\"item_number\" value=\"0001\">\n";
		echo "<input type=\"hidden\" name=\"amount\" value=\"25.00\">\n";
	} elseif ($date_select == "friday") {
		echo "<b>Friday Pass - $15.00 (USD)</b><br />\n";
		echo "<input type=\"hidden\" name=\"item_name\" value=\"Friday Pass\">\n";
		echo "<input type=\"hidden\" name=\"item_number\" value=\"0002\">\n";
		echo "<input type=\"hidden\" name=\"amount\" value=\"15.00\">\n";
	} elseif ($date_select == "saturday" && get_con_attendance_type($user_attendee_id) == 'LARP only') {
		echo "<b>MET LARP only Pass - $7.00 (USD)</b><br />\n";
		echo "<input type=\"hidden\" name=\"item_name\" value=\"MET LARP only Pass\">\n";
		echo "<input type=\"hidden\" name=\"item_number\" value=\"0005\">\n";
		echo "<input type=\"hidden\" name=\"amount\" value=\"7.00\">\n";
	} elseif ($date_select == "saturday") {
		echo "<b>Saturday Pass - $20.00 (USD)</b><br />\n";
		echo "<input type=\"hidden\" name=\"item_name\" value=\"Saturday Pass\">\n";
		echo "<input type=\"hidden\" name=\"item_number\" value=\"0003\">\n";
		echo "<input type=\"hidden\" name=\"amount\" value=\"20.00\">\n";
	} elseif ($date_select == "sunday") {
		echo "<b>Sunday Pass - $20.00 (USD)</b><br />\n";
		echo "<input type=\"hidden\" name=\"item_name\" value=\"Sunday Pass\">\n";
		echo "<input type=\"hidden\" name=\"item_number\" value=\"0004\">\n";
		echo "<input type=\"hidden\" name=\"amount\" value=\"20.00\">\n";
	}
			echo "<input type=\"hidden\" name=\"custom\" value=\"$user_attendee_id\">\n";
		    echo "<input type=\"hidden\" name=\"image_url\" value=\"http://loki.local/~plummer/uny-con/registration/images/PayPal-UNY-head-with-text-C.gif\">\n";
	echo "<input type=\"hidden\" name=\"no_note\" value=\"1\">\n";
	echo "<input type=\"hidden\" name=\"currency_code\" value=\"USD\">\n";
	echo "<input type=\"hidden\" name=\"lc\" value=\"US\">\n";
	echo "<input type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/sc-but-01.gif\" border=\"0\" name=\"submit\" alt=\"Make payments with PayPal - it's fast, free and secure!\">\n";
	echo "<input type=\"hidden\" name=\"add\" value=\"1\">\n";
	echo "</form>\n";
}

if ($pendingevents = get_attend_events($user_attendee_id, pending)) {
	print_paypal_links($pendingevents, $user_attendee_id);
	}

   	    echo "
   	          <form target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
      <input type=\"hidden\" name=\"cmd\" value=\"_cart\">
      <input type=\"hidden\" name=\"business\" value=\"registration@uny-con.com\">
<p><a href=\"event_list.php\"><img src=\"images/continue-registering.gif\" alt=\"Continue registering for events\" width=\"140\" height=\"40\" border=\"0\"></a> <a href=\"attendee_home.php\"><img src=\"images/view-schedule.gif\" alt=\"View your schedule\" width=\"140\" height=\"40\" border=\"0\"></a> 
      <input type=\"image\" src=\"http://loki.local/~plummer/uny-con/registration/images/view-paypal-cart.gif\" border=\"0\" name=\"submit\" alt=\"Make payments with PayPal - it's fast, free and secure!\">
      <input type=\"hidden\" name=\"display\" value=\"1\">
		<br>
		</p></form>";

do_html_footer(no_news);